function show<T>(params:T):T{
    return params
}
show<string>("xiaowang")
show<number>(123)

/**
 * 接受一个数组，获取数组的最大值
 */
function compare<T>(params:T[]):T{
    let max = params[0]
    params.forEach(item=>max = item>max?item:max)
    return max
}

let carray = [1,2,5,8]
compare<number>(carray)
compare<string>(["a","b","c"])

function compare2<T,K>(values:T,message:K){

}
compare2(1,"XIAOWANG")

/**
 * 泛型约束
 */
interface IUser2 {
    id:number,name:string,size:string
}
const student1:IUser2 = {
    id:1,name:"小王",size:"180"
}
function trace<T extends IUser2>(arg:T):T{
    const size = arg.size
    const value = arg.name
    return arg
}
trace<IUser2>(student1)
// trace<number>(123)

